﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using Microsoft.AspNetCore.Http;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using Extentions;
using TrainingReminderSystem.Model;
using TrainingReminderSystem.Dal;
using System.Threading.Tasks;

namespace TrainingReminderSystem.Bll
{
    /// <summary>
    /// 店铺文件 逻辑层
    /// </summary>
    public partial class SysFileBll : PcLoginedBll
    {
        #region 修改名称

        /// <summary>
        /// 修改名称
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        public AjaxResult<int> SysFileUpdateName(IFormCollection form)
        {
            int id = form["id"].ExToInt32();
            string name = form["name"].ExTrim().ExClearSql();
            string sql =
                $"update {nameof(SysFile)} set {nameof(SysFile.SysFileName)}='{name}' where {nameof(SysFile.ID)}={id}";
            using var db = Db;
            db.Database.ExecuteSqlRaw(sql);
            db.SaveChanges();
            return AjaxResult<int>.SuccessResult();
        }

        #endregion
    }
}
